package com.base.chat.ac;

import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.base.chat.R;
import com.base.chat.adapter.CreateGroupForFriendListAdapter;
import com.base.chat.adapter.MessageListAdapter;
import com.base.chat.bean.MyFriendListBean;
import com.base.chat.bean.SearchFriendsBean;
import com.base.chat.databinding.ActivityCreateGroupChatBinding;
import com.base.chat.databinding.FragmentMessageListBinding;
import com.base.chat.util.ChatStatEntity;
import com.base.chat.widget.ChatPopWindow;
import com.base.commonlib.base.CBaseBarMvpActivity;
import com.base.commonlib.resh.footer.ClassicsFooter;
import com.base.commonlib.resh.header.ClassicsHeader;
import com.base.commonlib.utils.RxBus2;
import com.base.commonlib.widget.RecyclerViewSpacesItemDecoration;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

@Route(path = "/chat/create_group")
public class CreateGroupChatActivity extends CBaseBarMvpActivity {

    private ActivityCreateGroupChatBinding mBinding;
    private List<SearchFriendsBean.Rows> mData=new ArrayList<>();
    private Disposable disposable;
    private CreateGroupForFriendListAdapter createGroupForFriendListAdapter;
    private List<MyFriendListBean> list =new ArrayList<>();

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_create_group_chat;
    }

    @Override
    protected void init() {
        super.init();
        mBinding = (ActivityCreateGroupChatBinding) mRootBinding;
        mBinding.smartRefreshLayout.setRefreshHeader(new ClassicsHeader(mContext));
        mBinding.smartRefreshLayout.setHeaderHeight(60);
        mBinding.smartRefreshLayout.setRefreshFooter(new ClassicsFooter(mContext));
    }

    @Override
    protected void start() {
        mBinding.tvRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        mBinding.tvLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        disposable = RxBus2.getInstance().doSubscribe(ChatStatEntity.class, new Consumer<ChatStatEntity>() {
            @Override
            public void accept(ChatStatEntity bean) throws Exception {
                if (bean.getState() == 0X0000010) {
                    if (mPresenter!=null){
                    }
                }
            }
        });
        createGroupForFriendListAdapter=new CreateGroupForFriendListAdapter(mContext,CreateGroupChatActivity.this,list);
        createGroupForFriendListAdapter.isHead(0);
        mBinding.rv.setAdapter(createGroupForFriendListAdapter);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        mBinding.rv.setLayoutManager(linearLayoutManager);
        mBinding.rv.addItemDecoration(new RecyclerViewSpacesItemDecoration
                (10, 10, 10, 10));
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        if (disposable != null) {
            disposable.dispose();
        }
    }

}
